home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
RTF
/
xtextview.h
< prev
Wrap
C/C++ Source or Header
|
1994-08-01
|
4KB
|
172 lines
/* $Header: /usr/people/pcd/Src/RTF/RCS/xtextview.h,v 1.1 92/11/23 12:58:53 pcd Exp Locker: pcd $
*/
#ifndef __xtextview_h
#define __xtextview_h
#include "view.h"
#include "textflow.h"
#include "textrect.h"
#include <X11/Xlib.h>
#include <assert.h>
typedef unsigned long Pixel;
class XTextFlow;
class XNewLineFlow;
class XTextView : public View{
friend class XTextFlow;
friend class XBitMap;
public:
XTextView(Display&, void* widget);
virtual Coord hinches(double i) const
{ return (Coord)((double)i * 254/10 * xdpmm()); }; //@@ make this tunable.
virtual Coord vinches(double i) const
{ return (Coord)((double)i * 254/10 * ydpmm()); }; //@@ make this tunable.
void text_flow(TextFlow& parent, TextPosition f, TextPosition l,
const CharacterFormat&);
void text_char(TextFlow& parent, TextPosition f, TextPosition l, char c,
const CharacterFormat&);
void new_line(TextFlow& parent, TextPosition f, TextPosition l,
Inches space_after);
void picture(TextFlow& parent, TextPosition f, TextPosition l,
Coord width, Coord height);
int render(Coord, Coord, Coord, Coord);
int region(TextPosition f, TextPosition l, Coord x[4], Coord y[4]);
int locate(TextPosition pos, int* top, int* bot);
Display* display() const
{ return display_; };
XFontStruct* font(char* spec) const;
GC get_gc(unsigned long mask, XGCValues& v);
void free_gc(GC gc);
Pixel color(int red, int green, int blue) const;
GC default_gc()
{ return DefaultGC(display(), DefaultScreen(display())); };
Pixel black()
{ return BlackPixel(display(), DefaultScreen(display())); };
Pixel white()
{ return WhitePixel(display(), DefaultScreen(display())); };
void drawable(Drawable, unsigned int depth);
protected:
void clear();
double xdpmm() const
{ return (double)WidthOfScreen(DefaultScreenOfDisplay(display())) /
WidthMMOfScreen(DefaultScreenOfDisplay(display())); };
double ydpmm() const
{ return (double)HeightOfScreen(DefaultScreenOfDisplay(display())) /
HeightMMOfScreen(DefaultScreenOfDisplay(display())); };
Drawable drawable() const
{ return drawable_; }; //@# what about 0?
unsigned int depth() const
{ /*assert(drawable_);*/
return depth_; };
private:
Display* display_;
Drawable drawable_;
int depth_;
void* widget_;
};
class XTextFlow : public TextFlow{
public:
XTextFlow(TextFlow& parent, TextPosition first, TextPosition last,
XTextView& view, const CharacterFormat&, char c=0);
~XTextFlow();
Qty character_shape(TextPosition, Qty, Extent, Extent&, int) const;
void render(TextPosition, Qty, Point) const;
protected:
XFontStruct* font() const
{ return font_; };
Display * display() const
{ return view_->display(); };
Drawable drawable() const
{ return view_->drawable(); };
GC gc() const
{ return gc_; };
private:
XTextView* view_;
char c_;
char ul_, super_, sub_;
void width(int w)
{ width_ = w; };
int width_;
GC gc_;
XFontStruct* font_;
};
class XNewLineFlow : public NewLineFlow{
public:
XNewLineFlow(TextFlow& parent, TextPosition first, TextPosition last,
XTextView& view, Inches sa)
: NewLineFlow(parent, first, last)
{ view_ = &view; space_after_ = sa; };
Coord font_ascent() const
{ return 10; }; //@@ use character formatting info !
Coord space_after() const
{ return view_->vinches(space_after_); };
private:
XTextView* view_;
Inches space_after_;
};
class XBitMap : public TextFlow{
public:
XBitMap(TextFlow& p, TextPosition f, TextPosition l,
XTextView& v, int width, int height);
~XBitMap();
Qty character_shape(TextPosition, Qty, Extent, Extent&, int) const;
void render(TextPosition, Qty, Point) const;
const XTextView* view() const
{ return view_; };
private:
int get_pixmap();
XTextView* view_;
Coord width_;
Coord height_;
Pixmap pixmap_;
};
#endif